<template>
  <div>
    <div class="inp">
      <van-cell-group inset border>
        <van-field v-model="psd" label="密码" placeholder="请输入密码" />
      </van-cell-group>
    </div>
    <div class="next">
      <van-button
        type="block"
        round
        color="red"
        @click="goLogin"
        :disabled="flag"
        >完成</van-button
      ><br />
    </div>
  </div>
</template>

<script>
import Vue from 'vue';
import { Toast } from 'vant';
import {doFinishRegister} from '../../api/reg3'

Vue.use(Toast);
export default {
  data() {
    return {
      psd: "",
    };
  },
  methods: {
    goLogin() {
    //   qAxios.post("/user/dofinishregister", {tel: localStorage.getItem("tel"),password: this.psd,})
    doFinishRegister({tel: localStorage.getItem("tel"),password: this.psd,})
        .then(() => {
         Toast('注册成功，请登录');
         this.$router.push('/login')
        });
    },
  },
  computed: {
    flag() {
      //密码强度校验，最少6位，包括至少1个大写字母，1个小写字母，1个数字
      if (
        /^\S*(?=\S{6,})(?=\S*\d)(?=\S*[A-Z])(?=\S*[a-z])\S*$/.test(this.psd)
      ) {
        return false;
      } else {
        return true;
      }
    },
  },
};
</script>

<style>
</style>